export default {
	/**
	 * 对象转URL
	 */
	urlEncode(data) {
		var _result = [];
		for (var key in data) {
			var value = data[key];
			if (value.constructor == Array) {
				value.forEach(function(_value) {
					_result.push(key + "=" + _value);
				});
			} else {
				_result.push(key + '=' + value);
			}
		}
		return _result.join('&');
	},
	/**
	 * url转对象
	 */
	urlToObj(str) {
		var obj = {};
		var arr1 = str.split("?");
		var arr2 = arr1[1].split("&");
		for (var i = 0; i < arr2.length; i++) {
			var res = arr2[i].split("=");
			obj[res[0]] = res[1];
		}
		return obj;
	}
}